Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disconnect api #1307

Merged
merged 3 commits into from
Jun 27, 2024
Merged

disconnect api #1307

merged 3 commits into from
Jun 27, 2024

Conversation

turbocrime
Copy link
Contributor

@turbocrime turbocrime commented Jun 16, 2024

Screen.Recording.2024-06-25.at.15.26.33.mov

closes #1192

adds disconnect method to page api

page injection is refactored as a class to more explicitly represent and control injection state

origin-agnostic connection init helpers are exported from client package

transport may convey a simple 'false' indicating termination

disconnect minifront ui ready in merged #1276 but commented out

still needs a type guard for the provider manifest

@turbocrime turbocrime requested review from grod220 and a team June 16, 2024 01:47
Copy link

changeset-bot bot commented Jun 16, 2024

🦋 Changeset detected

Latest commit: 7df3a3e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@penumbra-zone/client Major
@penumbra-zone/transport-chrome Major
@penumbra-zone/transport-dom Minor
minifront Patch
@penumbra-zone/services Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@turbocrime turbocrime force-pushed the turbocrime/disconnect-method-only branch 5 times, most recently from f052cef to b607f24 Compare June 25, 2024 07:19
@turbocrime turbocrime requested review from grod220 and a team June 25, 2024 08:27
@turbocrime turbocrime changed the title disconnect method only disconnect api Jun 25, 2024
readonly manifest: string;
}

declare global {
interface Window {
/** Records upon this global should identify themselves by a field name
* matching the origin of the provider. */
readonly [PenumbraSymbol]?: undefined | Readonly<Record<string, PenumbraInjection>>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: can we export some function like getInjectedWallet(walletOrigin) instead of using PenumbraSymbol?

I imagine external users implement the same API for wallets, so a set of function could help them:

  • getInjectedWallet(walletOrigin) – for dApp devs
  • getInjectedWallets() – list all browser wallets
  • injectWallet({ connect, disconnect, onConnectionChange ... }) – for wallet developers
  • onWalletInjected(callback) – a function that fires a callback each time a wallet is added (no need to wait for page reload). For this window[PenumbraSymbol] should probably be converted to a proxy object to control additions and deletions, idk.

getInjectedWallet could become the beginning of this improved DX

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see utils in create.ts

other aspects of this should probably happen after externally_connectable

injection should generally happen before page scripts load unless not approved.

adding callback functionality seems less useful, as the wallet client and all requests will be entirely promise-based anyway

react wrapper in another PR implements context and hooks, for that style

Copy link
Contributor

@VanishMax VanishMax Jun 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

injection should generally happen before page scripts load unless not approved

agree except for the case when user installs the extension and the page is loaded. Real life scenario:

  1. user enters the frontend
  2. frontend says "to get started, install the extension"
  3. they install the extension
  4. page didn't react – for now

i know it's a small thing but, in my opinion, developers will find the onWalletInjected(callback) useful

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the page must reload before a new content script can appear.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@turbocrime turbocrime force-pushed the turbocrime/disconnect-method-only branch from cc0465a to 31209d4 Compare June 25, 2024 20:35
Copy link
Contributor Author

@turbocrime turbocrime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @grod220 can this merge this week?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

readme added

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

elaborated comments

@turbocrime turbocrime force-pushed the turbocrime/disconnect-method-only branch from 31209d4 to 5814d33 Compare June 25, 2024 20:42
@turbocrime turbocrime requested a review from a team June 25, 2024 21:25
@turbocrime turbocrime force-pushed the turbocrime/disconnect-method-only branch from 1284f3e to 95db1fd Compare June 26, 2024 18:42
Copy link
Contributor

@VanishMax VanishMax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good to go!

@turbocrime turbocrime merged commit 47c6bc0 into main Jun 27, 2024
6 checks passed
@turbocrime turbocrime deleted the turbocrime/disconnect-method-only branch June 27, 2024 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disconnect wallet method
3 participants